package com.sheng.user.controller;

import java.util.List;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.sheng.entity.Product;
import com.sheng.service.ProductService;

/**
 * 产品控制类
 * @author Administrator
 *
 */
@RestController
public class ProductController {
	
	@Reference
	private ProductService productService;
	

	 @RequestMapping("/product/create")
	 public void create() {
		this.productService.createProduct();
	 }
	 
	 @RequestMapping("/product/{productId}/delete")
	 public void delete(@PathVariable Integer productId) {
		this.productService.remove(productId);
	 }
	
	 @RequestMapping("/product/{productId}/get")
	 public Product get(@PathVariable Integer productId) {
		return this.productService.getProduct(productId);
	 }
	 
	 
	 @RequestMapping("/product/listAll")
	 public List<Product> findListAll() {
		return this.productService.findProductAllList();
	 }
	 
	 @RequestMapping("/product/{productId}/update")
	 public void update(@PathVariable Integer productId,@RequestBody Product product) {
		 product.setProductId(productId);
		 this.productService.updateProduct(product);
	 }
	 
	 @RequestMapping("/product/query")
	 public List<Product> query(@RequestBody Product product) {
		return this.productService.findProductListByCondition(product);
	 }
	
}
